//
//  QzsettingViewController.m
//  YiqiMobile
//
//  Created by henry on 13-4-18.
//  Copyright (c) 2013年 henry. All rights reserved.
//

#import "QzsettingViewController.h"
#import "Utility.h"
#import "Config.h"
#import "Qzsetting0Cell.h"
#import "Qzsetting1Cell.h"
#import "HuodongTagViewController.h"
#import "QuartzCore/QuartzCore.h"



@interface QzsettingViewController ()

@end

@implementation QzsettingViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
         self.view.backgroundColor = UIColorFromRGB(0xfafafa);
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.titleView=[Utility getTitleView:@"圈子设定"];
    
    UIView *topView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 166)];
    topView.backgroundColor=[UIColor colorWithPatternImage:[Utility imageNamed:@"qz_top_background.png"]];
    [self.view addSubview:topView];
    
    [self.view addSubview:[Utility customButton:self action:@selector(uploadLogoaction:) normalImage:@"qz_top_add.png" lightedImage:@"qz_top_add.png"  frame:CGRectMake(18, 116, 84, 84) title:nil tag:333]];
	// Do any additional setup after loading the view.
    self.dataArray=[NSMutableArray array];
    [self.dataArray addObject:@[
                             @{@"name": @"用户(非邀请)加入活动",@"content":@"我授权管理员审核"},
                             @{@"name": @"博文发布",@"content":@"授权管理员审核"}
     ]];

    [self.dataArray addObject:@[
                          @{@"name": @"圈子名称",@"content":@"我的圈子"},
                          @{@"name": @"详细介绍",@"content":@"介绍的挺好"},
                          @{@"name": @"活动标签",@"content":@"活动标签"},
                          @{@"name": @"联系方式",@"content":@"020－888888"},
                          @{@"name": @"地址",@"content":@"广州市中山四路"}
                          ]];
    float height=367-198;
    if (iPhone5) {
         height+=88;
    }
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 198,320,height) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.separatorColor=[UIColor colorWithRed:228.0/255 green:228.0/255 blue:228.0/255 alpha:1.0];
    [self.view addSubview:self.tableView];
    
    
    
    
    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[Utility customButton:self action:@selector(backToPre) normalImage:@"navback_normal.png" lightedImage:@"navback_hover.png" frame:CGRectMake(0, 0, 58, 29) title:nil tag:10]];
    self.navigationItem.leftBarButtonItem=backBarButtonItem;
    
        UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[Utility customButton:self action:@selector(backToPre) normalImage:@"noti_save_normal.png" lightedImage:@"noti_save_hover.png" frame:CGRectMake(0, 0, 59, 29) title:nil tag:11]];
    
    self.navigationItem.rightBarButtonItem=rightBarButtonItem;
    

}
-(void)backToPre{
    [self dismissViewControllerAnimated:YES completion:nil];
}
-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    /*AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
    self.hidesBottomBarWhenPushed=NO;
    [app.tabBarController hideExistingTabBar];
    app.tabBarController.tabBarView.hidden=NO;*/
}

-(void) uploadLogoaction:(UIButton*)sender{

}

#pragma mark - TableViewdelegate&&TableViewdataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 59;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}


- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [[self.dataArray objectAtIndex:section] count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [self.dataArray count];
}



- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        static NSString *indentifier = @"Qzsetting0Cell";
        Qzsetting0Cell *cell =(Qzsetting0Cell*)[tableView dequeueReusableCellWithIdentifier:indentifier];
        if (!cell) {
            cell =[[Qzsetting0Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
        }
        NSDictionary *dict=[[self.dataArray objectAtIndex:indexPath.section]  objectAtIndex:indexPath.row];
        cell.label1.text=[dict objectForKey:@"name"];
        cell.label2.text=[dict objectForKey:@"content"];
        
        if (indexPath.row==0) {
            cell.flagImage.image=[Utility imageNamed:@"quanzi_shenhe_dot_normal.png"];
        }else{
           cell.flagImage.image=[Utility imageNamed:@"quanzi_shenhe_dot_hover.png"];
        }
        return cell;
    }else{
        static NSString *indentifier = @"Qzsetting1Cell";
        Qzsetting1Cell *cell =(Qzsetting1Cell*)[tableView dequeueReusableCellWithIdentifier:indentifier];
        if (!cell) {
            cell =[[Qzsetting1Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
        }
        NSDictionary *dict=[[self.dataArray objectAtIndex:indexPath.section]  objectAtIndex:indexPath.row];
        cell.label1.text=[dict objectForKey:@"name"];
        cell.label2.text=[dict objectForKey:@"content"];
         return cell;
    }
   
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==1&&indexPath.row==2) {
        HuodongTagViewController *huodongtag=[[HuodongTagViewController alloc] initWithNibName:nil bundle:nil];
        //huodongtag.hidesBottomBarWhenPushed=YES;
        //[self.tabBarController hideExistingTabBar];
        
        //self.tabBarController.quanziTabBarView.hidden=YES;
        [self.navigationController pushViewController:huodongtag animated:YES];
    }
   
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
